home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / machserver / 1.098 / fscache / fscache.h < prev    next >
C/C++ Source or Header  |  1991-03-30  |  23KB  |  605 lines

  1. /*
  2.  * fscache.h --
  3.  *
  4.  *    Declarations of interface to the Sprite file system cache. 
  5.  *
  6.  * Copyright 1989 Regents of the University of California
  7.  * Permission to use, copy, modify, and distribute this
  8.  * software and its documentation for any purpose and without
  9.  * fee is hereby granted, provided that the above copyright
  10.  * notice appear in all copies.  The University of California
  11.  * makes no representations about the suitability of this
  12.  * software for any purpose.  It is provided "as is" without
  13.  * express or implied warranty.
  14.  *
  15.  * $Header: /sprite/src/kernel/fscache/RCS/fscache.h,v 9.13 91/03/30 17:08:16 mgbaker Exp $ SPRITE (Berkeley)
  16.  */
  17.  
  18. #ifndef _FSCACHE
  19. #define _FSCACHE
  20.  
  21. #include <sync.h>
  22. #include <list.h>
  23. #include <fs.h>
  24. #include <user/time.h>
  25.  
  26. /* data structures */    
  27.  
  28.  
  29. /*
  30.  * Cache information for each file.
  31.  */
  32.  
  33. typedef struct Fscache_Attributes {
  34.     int        firstByte;    /* Cached version of desc. firstByte */
  35.     int        lastByte;    /* Cached version of desc. lastByte */
  36.     int        accessTime;    /* Cached version of access time */
  37.     int        modifyTime;    /* Cached version of modify time */
  38.     int        createTime;    /* Create time (won't change, but passed
  39.                  * to clients for use in
  40.                  * statistics-gathering) */
  41.     int        userType;    /* user advisory file type, defined in
  42.                  * user/fs.h */
  43.     /*
  44.      * The following fields are needed by Proc_Exec.
  45.      */
  46.     int        permissions;    /* File permissions */
  47.     int        uid;        /* User ID of owner */
  48.     int        gid;        /* Group Owner ID */
  49. } Fscache_Attributes;
  50.  
  51.  
  52.  
  53.  
  54. /*
  55.  * Structure to represent a cache block in the fileservers cache block 
  56.  * list and the core map list.
  57.  */
  58. typedef struct Fscache_FileInfo {
  59.     List_Links       links;       /* Links for the list of dirty files.
  60.                       THIS MUST BE FIRST in the struct */
  61.     List_Links       dirtyList;       /* List of dirty blocks for this file.
  62.                     * THIS MUST BE SECOND, see the macro
  63.                     * in fsBlockCache.c that depends on it. */
  64.     List_Links       blockList;      /* List of blocks for the file */
  65.     List_Links       indList;       /* List of indirect blocks for the file */
  66.     Sync_Lock       lock;       /* This is used to serialize cache access */
  67.     int           flags;       /* Flags to indicate the state of the
  68.                       file, defined below. */
  69.     int           version;       /* Used to verify validity of cached data */
  70.     struct Fs_HandleHeader *hdrPtr; /* Back pointer to I/O handle */
  71.     int           blocksInCache;  /* The number of blocks that this file has
  72.                       in the cache. */
  73.     int           blocksWritten;  /* The number of blocks that have been
  74.                     * written in a row without requiring a 
  75.                     * sync of the servers cache. */
  76.     int           numDirtyBlocks; /* The number of dirty blocks in the cache.*/
  77.     Sync_Condition noDirtyBlocks;  /* Notified when all write backs done. */
  78.     int           lastTimeTried;  /* Time that last tried to see if disk was
  79.                     * available for this block. */
  80.     int           oldestDirtyBlockTime;
  81.     Fscache_Attributes attr;       /* Local version of descriptor attributes. */
  82.     struct Fscache_Backend   *backendPtr;  
  83.             /* Routines for read/write/allocate/copy. */
  84. } Fscache_FileInfo;
  85.  
  86. /*
  87.  * Values for flags field in the Fscache_FileInfo struct.
  88.  *
  89.  *   FSCACHE_CLOSE_IN_PROGRESS    There is a close being done on this file so
  90.  *                no more delayed writes are allowed.
  91.  *   FSCACHE_SERVER_DOWN    The host that this file belongs is down.
  92.  *   FSCACHE_NO_DISK_SPACE    The domain that this file lives in has no
  93.  *                disk space.
  94.  *   FSCACHE_DOMAIN_DOWN    The domain to write to is not available.
  95.  *   FSCACHE_GENERIC_ERROR    An error occured for which we just hang onto
  96.  *                file blocks until we can write them out.
  97.  *   FSCACHE_SYNC_DONE        The server has been told to force all blocks
  98.  *                for this file to disk.
  99.  *   FSCACHE_FILE_BEING_WRITTEN    There already is a block cleaner working on
  100.  *                this process.
  101.  *   FSCACHE_FILE_ON_DIRTY_LIST    This file is on the dirty list.
  102.  *   FSCACHE_WRITE_TO_DISK    Want file forced to disk.
  103.  *   FSCACHE_FILE_NOT_CACHEABLE    This is set when files served by remote hosts
  104.  *                are no longer caching because of write sharing
  105.  *                or because the file is a directory.
  106.  *   FSCACHE_LARGE_FILE_MODE    This file is large enough such that we limit it
  107.  *                to only a few blocks in the cache.
  108.  *   FSCACHE_FILE_GONE        The file has been removed and any delayed
  109.  *                writes should be discarded.
  110. #ifdef SOSP91
  111.  *   FSCACHE_IS_DIR        File not cacheable because it's a directory.
  112. #endif SOSP91
  113.  *   FSCACHE_ALLOC_FAILED    Allocated failed due to disk full.  This
  114.  *                is used to throttle error messages.
  115.  *   FSCACHE_FILE_BEING_CLEANED
  116.  */
  117. #define    FSCACHE_CLOSE_IN_PROGRESS    0x0001
  118. #define    FSCACHE_SERVER_DOWN        0x0002
  119. #define    FSCACHE_NO_DISK_SPACE        0x0004
  120. #define FSCACHE_DOMAIN_DOWN        0x0008
  121. #define FSCACHE_GENERIC_ERROR        0x0010
  122. #define    FSCACHE_SYNC_DONE        0x0020
  123. #define FSCACHE_FILE_BEING_WRITTEN    0x0040
  124. #define    FSCACHE_FILE_ON_DIRTY_LIST    0x0080
  125. #define FSCACHE_WRITE_TO_DISK        0x0100
  126. #define FSCACHE_FILE_NOT_CACHEABLE    0x0200
  127. #define    FSCACHE_LARGE_FILE_MODE        0x0400
  128. #define FSCACHE_FILE_GONE        0x0800
  129. /* There's space for a new flag in here. */
  130. #ifdef SOSP91
  131. #define    FSCACHE_IS_DIR            0x1000
  132. #endif /* SOSP91 */
  133. #define FSCACHE_ALLOC_FAILED        0x2000
  134. #define    FSCACHE_FILE_FSYNC        0x4000
  135. #define    FSCACHE_FILE_DESC_DIRTY        0x8000
  136. #define    FSCACHE_FILE_BEING_CLEANED     0x10000
  137. #ifdef SOSP91
  138. /*
  139.  * The counters of why bytes leave the cache.
  140.  */
  141. #define    FSCACHE_REASON_FLAGS        0xFFF00000    
  142. #define    FSCACHE_CONSIST_WB        0x00100000
  143. #define    FSCACHE_CONSIST_WBINV        0x00200000
  144. #define    FSCACHE_SYNC                0x00400000
  145. #define    FSCACHE_REOPEN                0x00800000
  146. #define    FSCACHE_DETACH                0x01000000
  147. #define    FSCACHE_DESC                0x02000000
  148. #define    FSCACHE_TIME                0x04000000
  149. #define    FSCACHE_SPACE                0x08000000
  150. #define    FSCACHE_VM            0x10000000
  151. #define    FSCACHE_SHRINK            0x20000000
  152. #define    FSCACHE_LRU            0x40000000
  153.  
  154. typedef struct Fscache_ExtraStats {
  155.     unsigned int    consistWB;
  156.     unsigned int    cwbDLife;
  157.     unsigned int    consistWBInv;
  158.     unsigned int    cwbiDLife;
  159.     unsigned int    sync;
  160.     unsigned int    syncDLife;
  161.     unsigned int    reopen;
  162.     unsigned int    reDLife;
  163.     unsigned int    detach;
  164.     unsigned int    detDLife;
  165.     unsigned int    desc;
  166.     unsigned int    descDLife;
  167.     unsigned int    time;
  168.     unsigned int    timeDLife;
  169.     unsigned int    space;
  170.     unsigned int    spaceDLife;
  171.     unsigned int    vm;
  172.     unsigned int    vmDLife;
  173.     unsigned int    shrink;
  174.     unsigned int    shrinkDLife;
  175.     unsigned int    lru;
  176.     unsigned int    lruDLife;
  177.     unsigned int    unknown;
  178.     unsigned int    unDLife;
  179.     unsigned int    cleanVm;
  180.     unsigned int    cVmLife;
  181.     unsigned int    unRcleanVm;
  182.     unsigned int    cleanShrink;
  183.     unsigned int    cShrinkLife;
  184.     unsigned int    unRcleanShrink;
  185.     unsigned int    cleanLru;
  186.     unsigned int    cLruLife;
  187.     unsigned int    unRcleanLru;
  188. } Fscache_ExtraStats;
  189.  
  190. extern    Fscache_ExtraStats    fscache_ExtraStats;
  191.  
  192. #endif SOSP91
  193.  
  194.  
  195. /*
  196.  * Structure to represent a cache block in the fileservers cache block 
  197.  * list and the core map list.
  198.  */
  199. typedef struct Fscache_Block {
  200.     List_Links    dirtyLinks;    /* Links to put block into list of dirty
  201.                  * blocks for the file.  THIS MUST BE FIRST 
  202.                  * in the struct. It may be used by the
  203.                  * cache backend's after a Fetch_DirtyBlock
  204.                  * call.  */
  205.     List_Links    useLinks;    /* Links to put block into list of unused 
  206.                    cache blocks or LRU list of cache blocks.
  207.                    THIS MUST BE SECOND in the struct. */
  208.     List_Links    fileLinks;    /* Links to put block into list of blocks
  209.                  * for the file.  There are two lists, either
  210.                  * regular or for indirect blocks. */
  211.     time_t timeDirtied;        /* Time in seconds that block was
  212.                    dirtied if at all. */
  213.     time_t timeReferenced;    /* Time in seconds that this block was
  214.                  * last referenced. */
  215.     Address    blockAddr;    /* Kernel virtual address where data for
  216.                    cache block is at. */
  217.     Fscache_FileInfo *cacheInfoPtr;    /* Reference to file's cache info. */
  218.     int        fileNum;    /* For consistency checks */
  219.     int        blockNum;    /* The number of this block in the file. */
  220.     int        diskBlock;    /* The block number on disk for this block. 
  221.                    For remote blocks this equals blockNum. */
  222.     int        blockSize;    /* The number of valid bytes in this block. */
  223.     int        refCount;    /* Number of times that the block is referenced.
  224.                    0 means is unreferenced. */
  225.     Sync_Condition ioDone;    /* Notified when block is unlocked after I/O */
  226.     int        flags;        /* Flags to indicate state of block. */
  227. } Fscache_Block;
  228.  
  229. /* 
  230.  * Flags for a Fscache_Block: 
  231.  * 
  232.  *   FSCACHE_BLOCK_FREE            The block is not being used.
  233.  *   FSCACHE_BLOCK_ON_DIRTY_LIST    The block is on the dirty list.
  234.  *   FSCACHE_BLOCK_BEING_WRITTEN    The block is in the process of being
  235.  *                    written to disk.
  236.  *   FSCACHE_BLOCK_DIRTY        The block contains dirty data.
  237.  *   FSCACHE_BLOCK_DELETED        This block has been deleted.  This
  238.  *                    flag is set when a block is to be
  239.  *                    invalidated after it has been cleaned.
  240.  *   FSCACHE_MOVE_TO_FRONT        After this block has finished being
  241.  *                    cleaned move it to the front of the
  242.  *                    LRU list.
  243.  *   FSCACHE_WRITE_BACK_WAIT        This block is being written out by 
  244.  *                    FsCacheWriteBack which is waiting
  245.  *                    for all such blocks to be written out.
  246.  *   FSCACHE_BLOCK_WRITE_LOCKED        This block is being modified.
  247.  *   FSCACHE_BLOCK_NEW            This block was just created.
  248.  *   FSCACHE_BLOCK_CLEANER_WAITING    The block cleaner is waiting for this
  249.  *                    block to become unlocked in order to
  250.  *                    write it out.
  251.  *   FSCACHE_NOT_MAPPED            This cache block does not have
  252.  *                    physical memory behind it.
  253.  *   FSCACHE_IND_BLOCK            This block is an indirect block.
  254.  *   FSCACHE_DESC_BLOCK            This block is a file descriptor block.
  255.  *   FSCACHE_DIR_BLOCK            This is a directory block.
  256.  *   FSCACHE_DATA_BLOCK            This is a data block.
  257.  *   FSCACHE_READ_AHEAD_BLOCK        This block was read ahead.
  258.  *   FSCACHE_IO_IN_PROGRESS        IO is in progress on this block.
  259.  *   FSCACHE_CANT_BLOCK
  260.  *   FSCACHE_DONT_BLOCK            Don't block if the cache block is
  261.  *                    already locked.    
  262.  *   FSCACHE_PIPE_BLOCK            This is a block that is permanently
  263.  *                    locked so that it can serve as the
  264.  *                    data area for a pipe. (NOT USED)
  265.  *   FSCACHE_WRITE_THRU_BLOCK        This block is being written through by
  266.  *                    the caller to Fscache_UnlockBlock.
  267.  *   FSCACHE_BLOCK_BEING_CLEANED        The block is being cleaned.
  268.  */
  269. #define    FSCACHE_BLOCK_FREE            0x000001
  270. #define    FSCACHE_BLOCK_ON_DIRTY_LIST        0x000002
  271. #define    FSCACHE_BLOCK_BEING_WRITTEN        0x000004
  272. #define    FSCACHE_BLOCK_DIRTY            0x000008
  273. #define    FSCACHE_BLOCK_DELETED            0x000010
  274. #define    FSCACHE_MOVE_TO_FRONT            0x000020
  275. #define    FSCACHE_WRITE_BACK_WAIT            0x000040
  276. #define    FSCACHE_BLOCK_WRITE_LOCKED        0x000100
  277. #define    FSCACHE_BLOCK_NEW            0x000200
  278. #define    FSCACHE_BLOCK_CLEANER_WAITING        0x000400
  279. #define    FSCACHE_NOT_MAPPED            0x000800
  280. #define    FSCACHE_IND_BLOCK            0x001000
  281. #define    FSCACHE_DESC_BLOCK            0x002000
  282. #define    FSCACHE_DIR_BLOCK            0x004000
  283. #define    FSCACHE_DATA_BLOCK            0x008000
  284. #define    FSCACHE_READ_AHEAD_BLOCK        0x010000
  285. #define    FSCACHE_IO_IN_PROGRESS            0x020000
  286. #define FSCACHE_DONT_BLOCK            0x040000
  287. #define FSCACHE_PIPE_BLOCK            0x080000
  288. #define    FSCACHE_WRITE_THRU_BLOCK        0x100000
  289. #define    FSCACHE_CANT_BLOCK            0x200000
  290. #define    FSCACHE_BLOCK_BEING_CLEANED        0x400000
  291. #ifdef SOSP91
  292. #define    FSCACHE_BLOCK_REASON                  0xFF000000
  293. #define    FSCACHE_BLOCK_LRU                  0x01000000
  294. #define    FSCACHE_BLOCK_VM                  0x02000000
  295. #define    FSCACHE_BLOCK_SHRINK                  0x04000000
  296. #endif SOSP91
  297.  
  298.  
  299. /*
  300.  * Macro to get the block address field of the Fscache_Block struct.
  301.  */
  302.  
  303. #define    Fscache_BlockAddress(cacheBlockPtr) ((cacheBlockPtr)->blockAddr)
  304.  
  305. /*
  306.  * Constant to pass to Fscache_FileWriteBack, which takes block numbers as
  307.  * arguments.
  308.  */
  309. #define FSCACHE_LAST_BLOCK    -1
  310.  
  311. /*
  312.  * Constants to pass as flags to Fscache_FileWriteBack.
  313.  *
  314.  *    FSCACHE_FILE_WB_WAIT        Wait for blocks to be written back.
  315.  *    FSCACHE_WRITE_BACK_INDIRECT    Write back indirect blocks.
  316.  *    FSCACHE_WRITE_BACK_AND_INVALIDATE    Invalidate after writing back.
  317.  *    FSCACHE_WB_MIGRATION        Invalidation due to migration (for
  318.  *                    statistics purposes only).
  319.  *    FSCACHE_WRITE_BACK_DESC_ONLY     Only writeback the descriptor.
  320.  */
  321. #define FSCACHE_FILE_WB_WAIT        0x1
  322. #define    FSCACHE_WRITE_BACK_INDIRECT    0x2
  323. #define    FSCACHE_WRITE_BACK_AND_INVALIDATE    0x4
  324. #define    FSCACHE_WB_MIGRATION    0x8
  325. #define    FSCACHE_WRITE_BACK_DESC_ONLY    0x10
  326.  
  327. /*
  328.  * Constants to pass as flags to FsUnlockCacheBlock.
  329.  *
  330.  *    FSCACHE_DELETE_BLOCK        The block should be deleted when it is unlocked.
  331.  *    FSCACHE_CLEAR_READ_AHEAD   Clear the read ahead flag from the block.
  332.  *    FSCACHE_BLOCK_UNNEEDED     This block is not needed anymore.  Throw it away
  333.  *                as soon as possible.
  334.  *    FSCACHE_DONT_WRITE_THRU    Don't write this block through to disk.
  335.  *
  336.  * Also can pass one of the 4 block types defined above (0x1000 - 0x8000).
  337.  */
  338. #define    FSCACHE_DELETE_BLOCK            0x0001
  339. #define    FSCACHE_CLEAR_READ_AHEAD        0x0002
  340. #define FSCACHE_BLOCK_UNNEEDED        0x0004
  341. #define    FSCACHE_DONT_WRITE_THRU        0x0008
  342.  
  343. /*
  344.  * Flags for Fscache_Trunc
  345.  *    FSCACHE_TRUNC_DELETE    Truncate because the file is deleted.  This
  346.  *                is used to prevent delayed writes during the
  347.  *                truncation of the file.
  348.  */
  349. #define FSCACHE_TRUNC_DELETE        0x1
  350.  
  351. typedef struct Fscache_BackendRoutines {
  352.     /*
  353.      *    FooAllocate(hdrPtr, offset, bytes, flags, blockAddrPtr, newBlockPtr)
  354.      *        Fs_HandleHeader *hdrPtr;            (File handle)
  355.      *        int        offset;            (Byte offset)
  356.      *        int        bytes;            (Bytes to allocate)
  357.      *        int        flags;            (FSCACHE_DONT_BLOCK)
  358.      *        int        *blockAddrPtr;        (Returned block number)
  359.      *        Boolean        *newBlockPtr;        (TRUE if new block)
  360.      *    FooTruncate(hdrPtr, size, delete)
  361.      *        Fs_HandleHeader    *hdrPtr;        (File handle)
  362.      *        int        size;            (New size)
  363.      *        Boolean        delete;            (TRUE if file being 
  364.      *                             removed)
  365.      *    FooBlockRead(hdrPtr, blockPtr,remoteWaitPtr)
  366.      *        Fs_HandleHeader    *hdrPtr;        (File handle)
  367.      *        Fscache_Block    *blockPtr;        (Cache block to read)
  368.      *        Sync_RemoteWaiter *remoteWaitPtr;    (For remote waiting)
  369.      *    FooBlockWrite(hdrPtr, blockPtr, lastDirtyBlock)
  370.      *        Boolean        lastDirtyBlock;        (Indicates last block)
  371.      *    FooReallocBlock(data, callInfoPtr)
  372.      *        ClientData    data =     blockPtr;  (Cache block to realloc)
  373.      *        Proc_CallInfo    *callInfoPtr;    
  374.      *    FooStartWriteBack(backendPtr)
  375.      *        Fscache_Backend *backendPtr;    (Backend to start writeback.)
  376.      */ 
  377.     ReturnStatus (*allocate) _ARGS_((Fs_HandleHeader *hdrPtr, int offset,
  378.                     int numBytes, int flags, int *blockAddrPtr,
  379.                     Boolean *newBlockPtr));
  380.     ReturnStatus (*truncate) _ARGS_((Fs_HandleHeader *hdrPtr, int size, 
  381.                      Boolean delete));
  382.     ReturnStatus (*blockRead) _ARGS_((Fs_HandleHeader *hdrPtr, 
  383.                       Fscache_Block *blockPtr, 
  384.                       Sync_RemoteWaiter *remoteWaitPtr));
  385.     ReturnStatus (*blockWrite) _ARGS_((Fs_HandleHeader *hdrPtr, 
  386.                        Fscache_Block *blockPtr, int flags));
  387.     void     (*reallocBlock) _ARGS_((ClientData data, 
  388.                      Proc_CallInfo *callInfoPtr));
  389.  
  390.     ReturnStatus (*startWriteBack) _ARGS_((struct Fscache_Backend *backendPtr));
  391. } Fscache_BackendRoutines;
  392.  
  393.  
  394. /*
  395.  * Routines and data structures defining a backend to the cache. 
  396.  */
  397. typedef struct Fscache_Backend {
  398.     List_Links    cacheLinks;    /* Used by fscacheBlocks.c to link backends
  399.                  * onto a list. Must be first in structure! */
  400.     int        flags;        /* See below. */
  401.     ClientData    clientData;    /* ClientData for the backend. */
  402.     List_Links    dirtyListHdr;   /* List of dirty files for this backend. */
  403.  
  404.     Fscache_BackendRoutines ioProcs; /* Routines for backend. */
  405. } Fscache_Backend;
  406.  
  407.  
  408. /*
  409.  * Read-ahead is used for both local and remote files that are cached.
  410.  * The following structure is used to synchronize read ahead with other I/O.
  411.  */
  412.  
  413. typedef struct Fscache_ReadAheadInfo {
  414.     Sync_Lock        lock;        /* Access to this state is monitored */
  415.     int            count;        /* Number of read aheads in progress */
  416.     Boolean        blocked;    /* TRUE if read ahead is blocked */
  417.     Sync_Condition    done;        /* Notified when there are no more read
  418.                      * aheads in progress. */
  419.     Sync_Condition    okToRead;    /* Notified when there are no more
  420.                      * conflicts with read ahead. */
  421. } Fscache_ReadAheadInfo;            /* 24 BYTES */
  422.  
  423. #define    FSCACHE_NUM_DOMAIN_TYPES    2
  424.  
  425. #ifndef CLEAN
  426. #define FSCACHE_DEBUG_PRINT(string) \
  427.     if (fsconsist_Debug) {\
  428.         printf(string);\
  429.     }
  430. #define FSCACHE_DEBUG_PRINT1(string, arg1) \
  431.     if (fsconsist_Debug) {\
  432.         printf(string, arg1);\
  433.     }
  434. #define FSCACHE_DEBUG_PRINT2(string, arg1, arg2) \
  435.     if (fsconsist_Debug) {\
  436.         printf(string, arg1, arg2);\
  437.     }
  438. #define FSCACHE_DEBUG_PRINT3(string, arg1, arg2, arg3) \
  439.     if (fsconsist_Debug) {\
  440.         printf(string, arg1, arg2, arg3);\
  441.     }
  442. #else
  443. #define FSCACHE_DEBUG_PRINT(string)
  444. #define FSCACHE_DEBUG_PRINT1(string, arg1)
  445. #define FSCACHE_DEBUG_PRINT2(string, arg1, arg2)
  446. #define FSCACHE_DEBUG_PRINT3(string, arg1, arg2, arg3)
  447. #endif not CLEAN
  448.  
  449. /*
  450.  * The cache uses a number of Proc_ServerProcs to do write-backs.
  451.  * FSCACHE_MAX_CLEANER_PROCS defines the maximum number, and this
  452.  * is used to configure the right number of Proc_ServerProcs.
  453.  */
  454. #define FSCACHE_MAX_CLEANER_PROCS    3
  455.  
  456. extern int    fscache_MaxBlockCleaners;
  457. extern Boolean    fscache_RATracing;
  458. extern int    fscache_NumReadAheadBlocks;
  459.  
  460. extern List_Links *fscacheFullWaitList;
  461.  
  462. /* procedures */
  463.  
  464. /*
  465.  * Block Cache routines. 
  466.  */
  467. #ifdef SOSP91
  468. extern void Fscache_AddBlockToStats _ARGS_((Fscache_FileInfo *cacheInfoPtr, Fscache_Block *blockPtr));
  469. extern void Fscache_AddCleanStats _ARGS_((unsigned int flags, Fscache_Block *blockPtr));
  470. #endif SOSP91
  471. extern void Fscache_WriteBack _ARGS_((unsigned int writeBackTime,
  472.             int *blocksSkippedPtr, Boolean writeBackAll));
  473. extern ReturnStatus Fscache_FileWriteBack _ARGS_((
  474.             Fscache_FileInfo *cacheInfoPtr, int firstBlock, 
  475.             int lastBlock, int flags, int *blocksSkippedPtr));
  476. extern void Fscache_FileInvalidate _ARGS_((Fscache_FileInfo *cacheInfoPtr, 
  477.             int firstBlock, int lastBlock));
  478. extern void Fscache_Empty _ARGS_((int *numLockedBlocksPtr));
  479. extern void Fscache_CheckFragmentation _ARGS_((int *numBlocksPtr, 
  480.             int *totalBytesWastedPtr, int *fragBytesWastedPtr));
  481.  
  482. extern ReturnStatus Fscache_CheckVersion _ARGS_((
  483.             Fscache_FileInfo *cacheInfoPtr, int version, 
  484.             int clientID));
  485. extern ReturnStatus Fscache_Consist _ARGS_((
  486.             Fscache_FileInfo *cacheInfoPtr, int flags, 
  487.             Fscache_Attributes *cachedAttrPtr));
  488.  
  489. extern void Fscache_SetMinSize _ARGS_((int minBlocks));
  490. extern void Fscache_SetMaxSize _ARGS_((int maxBlocks));
  491. extern void Fscache_BlocksUnneeded _ARGS_((Fs_Stream *streamPtr,
  492.                 int offset, int numBytes, Boolean objectFile));
  493. extern void Fscache_DumpStats _ARGS_((ClientData dummy));
  494. extern void Fscache_GetPageFromFS _ARGS_((time_t timeLastAccessed, 
  495.                 int *pageNumPtr));
  496.  
  497. extern void Fscache_FileInfoInit _ARGS_((Fscache_FileInfo *cacheInfoPtr,
  498.         Fs_HandleHeader *hdrPtr, int version, Boolean cacheable,
  499.         Fscache_Attributes *attrPtr, Fscache_Backend *backendPtr));
  500. extern void Fscache_InfoSyncLockCleanup _ARGS_((Fscache_FileInfo *cacheInfoPtr));
  501. extern Fscache_Backend *Fscache_RegisterBackend _ARGS_((
  502.         Fscache_BackendRoutines *ioProcsPtr, ClientData clientData, 
  503.         int flags));
  504. extern void Fscache_UnregisterBackend _ARGS_((Fscache_Backend *backendPtr));
  505.  
  506. extern void Fscache_FetchBlock _ARGS_((Fscache_FileInfo *cacheInfoPtr, 
  507.         int blockNum, int flags, Fscache_Block **blockPtrPtr, 
  508.         Boolean *foundPtr));
  509. extern void Fscache_IODone _ARGS_((Fscache_Block *blockPtr));
  510. extern void Fscache_UnlockBlock _ARGS_((Fscache_Block *blockPtr, 
  511.         time_t timeDirtied, int diskBlock, int blockSize, 
  512.         int flags));
  513. extern void Fscache_BlockTrunc _ARGS_((Fscache_FileInfo *cacheInfoPtr, 
  514.         int blockNum, int newBlockSize));
  515.  
  516. extern void Fscache_Init _ARGS_((int blockHashSize));
  517. extern int Fscache_PreventWriteBacks _ARGS_((Fscache_FileInfo *cacheInfoPtr));
  518. extern void Fscache_AllowWriteBacks _ARGS_((Fscache_FileInfo *cacheInfoPtr));
  519. extern Fscache_FileInfo *Fscache_GetDirtyFile _ARGS_((
  520.             Fscache_Backend *backendPtr, Boolean fsyncOnly, 
  521.             Boolean (*fileMatchProc)(), ClientData clientData));
  522. extern void Fscache_ReturnDirtyFile _ARGS_((Fscache_FileInfo *cacheInfoPtr,
  523.         Boolean onFront));
  524. extern Fscache_Block *Fscache_GetDirtyBlock _ARGS_((
  525.         Fscache_FileInfo *cacheInfoPtr, 
  526.         Boolean (*blockMatchProc)(Fscache_Block *blockPtr, 
  527.                       ClientData clientData), 
  528.         ClientData clientData, int *lastDirtyBlockPtr));
  529. extern void Fscache_ReturnDirtyBlock _ARGS_((Fscache_Block *blockPtr,
  530.             ReturnStatus status));
  531. extern ReturnStatus Fscache_PutFileOnDirtyList _ARGS_((
  532.             Fscache_FileInfo *cacheInfoPtr, int flags));
  533. extern ReturnStatus Fscache_RemoveFileFromDirtyList _ARGS_((
  534.             Fscache_FileInfo *cacheInfoPtr));
  535.  
  536. /*
  537.  * Cache operations.  There are I/O operations, plus routines to deal
  538.  * with the cached I/O attributes like access time, modify time, and size.
  539.  */
  540.  
  541. extern ReturnStatus Fscache_Read _ARGS_((Fscache_FileInfo *cacheInfoPtr,
  542.         int flags, register Address buffer, int offset, int *lenPtr,
  543.         Sync_RemoteWaiter *remoteWaitPtr));
  544. extern ReturnStatus Fscache_Write _ARGS_((Fscache_FileInfo *cacheInfoPtr, 
  545.         int flags,  Address buffer, int offset, int *lenPtr, 
  546.         Sync_RemoteWaiter *remoteWaitPtr));
  547. extern ReturnStatus Fscache_BlockRead _ARGS_((Fscache_FileInfo *cacheInfoPtr,
  548.         int blockNum, Fscache_Block **blockPtrPtr, int *numBytesPtr, 
  549.         int blockType, Boolean allocate));
  550. extern ReturnStatus Fscache_Trunc _ARGS_((Fscache_FileInfo *cacheInfoPtr, 
  551.                     int length, int flags));
  552.  
  553.  
  554. extern Boolean Fscache_UpdateFile _ARGS_((Fscache_FileInfo *cacheInfoPtr, 
  555.         Boolean openForWriting, int version, Boolean cacheable, 
  556.         Fscache_Attributes *attrPtr));
  557. extern void Fscache_UpdateAttrFromClient _ARGS_((int clientID, 
  558.         Fscache_FileInfo *cacheInfoPtr,  Fscache_Attributes *attrPtr));
  559. extern void Fscache_UpdateDirSize _ARGS_((Fscache_FileInfo *cacheInfoPtr, 
  560.         int newLastByte));
  561. extern void Fscache_UpdateAttrFromCache _ARGS_((Fscache_FileInfo *cacheInfoPtr,
  562.         Fs_Attributes *attrPtr));
  563. extern void Fscache_GetCachedAttr _ARGS_((Fscache_FileInfo *cacheInfoPtr, 
  564.         int *versionPtr, Fscache_Attributes *attrPtr));
  565. extern void Fscache_UpdateCachedAttr _ARGS_((Fscache_FileInfo *cacheInfoPtr,
  566.         Fs_Attributes *attrPtr, int flags));
  567.  
  568.  
  569. extern Boolean Fscache_OkToScavenge _ARGS_((Fscache_FileInfo *cacheInfoPtr));
  570.  
  571.  
  572. extern int Fscache_ReserveBlocks _ARGS_((Fscache_Backend *backendPtr, 
  573.             int numResBlocks, int numNonResBlocks));
  574.  
  575. extern void Fscache_ReleaseReserveBlocks _ARGS_((Fscache_Backend *backendPtr,
  576.             int numBlocks));
  577.  
  578. /*
  579.  * Read ahead routines.
  580.  */
  581.  
  582. extern void Fscache_ReadAheadInit _ARGS_((Fscache_ReadAheadInfo *readAheadPtr));
  583. extern void Fscache_ReadAheadSyncLockCleanup _ARGS_((
  584.             Fscache_ReadAheadInfo *readAheadPtr));
  585. extern void FscacheReadAhead _ARGS_((Fscache_FileInfo *cacheInfoPtr, 
  586.                 int blockNum));
  587.  
  588. extern void Fscache_WaitForReadAhead _ARGS_((
  589.             Fscache_ReadAheadInfo *readAheadPtr));
  590. extern void Fscache_AllowReadAhead _ARGS_((Fscache_ReadAheadInfo *readAheadPtr));
  591.  
  592. extern void FscacheReadAhead _ARGS_((Fscache_FileInfo *cacheInfoPtr,
  593.             int blockNum));
  594.  
  595.  
  596. extern void FscacheBackendIdle _ARGS_((Fscache_Backend *backendPtr));
  597. extern void FscacheFinishRealloc _ARGS_((Fscache_Block *blockPtr, 
  598.             int diskBlock));
  599.  
  600. extern void Fscache_CountBlocks _ARGS_((int serverID, int majorNumber,
  601.             int *numBlocksPtr, int *numDirtyBlocksPtr));
  602.  
  603. #endif /* _FSCACHE */
  604.  
  605.